<?php 
$show_validator = true;
include TMPL_PATH.'public/header.phtml';
?>
<script type="text/javascript" src="/statics/xheditor/xheditor-zh-cn.min.js"></script>
<div class="subnav">
    <div class="content-menu ib-a blue line-x">
        <a href='<?php echo U('payment/payment_list');?>'><em>支付方式列表</em></a><span>|</span>
        <a href='javascript:;' class="on"><em>支付插件配置</em></a>
    </div>
</div>
<div class="pad_10">
<div class="col-tab">
<ul class="tabBut cu-li">
<?php 
$langCount = 0;
if(isset($languageList) && $languageList){
		$langCount = count($languageList);
}
$langCount++;
?>
<?php 
	if(isset($languageList) && $languageList):
		$i = 0;
		foreach ($languageList as $language_id => $language_name):
			$i++;
	?>
<li id="tab_setting_<?php echo $i;?>" <?php if($i==1)echo 'class="on"';?> onclick="SwapTab('setting','on','',<?php echo $langCount;?>,<?php echo $i;?>);"><?php echo $language_name;?></li>
<?php 
		endforeach;
	endif;
	?>
<li id="tab_setting_<?php echo $langCount;?>" onclick="SwapTab('setting','on','',<?php echo $langCount;?>,<?php echo $langCount;?>);">基本选项</li>
</ul>
<form name="myform" action="__SELF__" method="post" id="myform">
	<?php 
	if(isset($languageList) && $languageList):
		$i = 0;
		foreach ($languageList as $language_id => $language_name):
			$i++;
	?>
	<div id="div_setting_<?php echo $i;?>" class="contentList pad-10 <?php if($i>1)echo 'hidden';?>">
		<table width="100%" class="table_form contentWrap">
			<tr>
				<th width="120">支付名称：</th> 
				<td><input type="text" name="payment[<?php echo $language_id;?>][title]" value="<?php echo $payment['items'][$language_id]['title'];?>" class="input-text" style="width:50%;"/></td>
			</tr>
			<tr>
				<th>支付描述：</th>
				<td><textarea class="xheditor"  name="payment[<?php echo $language_id;?>][description]" style="height:200px;width:80%;"><?php echo $payment['items'][$language_id]['description'];?></textarea></td>
			</tr>
			<tr style="display:none">
				<th>支付说明：</th>
				<td><textarea  name="payment[<?php echo $language_id;?>][note]"><?php echo $payment['items'][$language_id]['note'];?></textarea></td>
			</tr>
		</table>
	</div>
	<?php 
		endforeach;
	endif;
	?>
	<div id="div_setting_<?php echo $langCount;?>" class="contentList pad-10 hidden">
	<table width="100%" class="table_form contentWrap">
	<?php 
		if(isset($paymentFields) && $paymentFields):
			foreach ($paymentFields as $fpk => $fvalue):
			$default = isset($payment['config'][$fpk]) ? $payment['config'][$fpk] : null;
				if(is_string($fvalue)):
	?>
	<tr>
	<th  width="120"><?php echo $fvalue;?>：</th> 
	<td><input type="text" name="config[<?php echo $fpk;?>]" value="<?php echo $default;?>" class="input-text"/></td>
	</tr>
	<?php elseif(is_array($fvalue)):?>
	<tr>
	<th width="120"><?php echo $fvalue['name'];?>：</th> 
	<td><select name="config[<?php echo $fpk?>]">
		<?php 
					if(isset($fvalue['options']) && $fvalue['options']):
						foreach ($fvalue['options'] as $opvalue => $opname):
							$fvalue['default'] = $default ? $default : $fvalue['default'];
		?>
				<option value="<?php echo $opvalue;?>" <?php if($fvalue['default']==$opvalue)echo 'selected';?>><?php echo $opname;?></option>
		<?php 
						endforeach;
					endif;
		?>
	</select></td>
	</tr>
	<?php 
				endif;
			endforeach;
		endif;
	?>
	<tr>
		<th width="120">手续费设置：</th>
		<td>
			<label><input type="radio" onclick="radioselect(this)" <?php if($payment['poundage_type']==1)echo'checked="checked"';?> value="1" name="poundage_type">按百分比收费</label>&nbsp;&nbsp;
			<label><input type="radio" onclick="radioselect(this)" value="2" <?php if($payment['poundage_type']==2)echo'checked="checked"';?> name="poundage_type">按固定额度收费</label>
		</td>
	</tr>
	<tr id="poundage_rate">
		<th></th>
		<td>
			费率：<input type="text" value="<?php echo $payment['poundage_rate'];?>" name="poundage_rate" class="input-text" size="5">% &nbsp;&nbsp; 说明：顾客将支付订单总金额乘以此费率作为手续费；
		</td>
	</tr>
	<tr style="display: none;" id="poundage_fix">
		<th></th>
			<td>
				金额：<input type="text" value="<?php echo $payment['poundage_fix'];?>" name="poundage_fix" class="input-text" size="5">元 &nbsp;&nbsp; 说明：顾客每笔订单需要支付的手续费；
			</td>
	</tr>
	<tr>
	  <th>排序：</th>
	  <td><input type="text" name="listorder" class="input-text" size="5" value="<?php echo $payment['listorder']?>"/></td>
	</tr>
	</table>
	</div>
    <div class="bk15"></div>
    <input name="name" type="hidden" value="<?php echo $payment['name'];?>"/>
    <input name="online" type="hidden" value="<?php echo $payment['online'];?>"/>
    <input name="dosubmit" type="submit" value="提交" class="button" id="dosubmit" />
</form>
</div>
</div>
</body>
</html>
<script type="text/javascript">
function radioselect(obj)
{
	if(obj.value==1)
	{
		$('#poundage_rate').show();
		$('#poundage_fix').hide();
	}
	else
	{
		$('#poundage_fix').show();
		$('#poundage_rate').hide();
	}
}
</script>